package com.brainhealth.web.controller.customer;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.brainhealth.common.annotation.Log;
import com.brainhealth.common.core.controller.BaseController;
import com.brainhealth.common.core.domain.AjaxResult;
import com.brainhealth.common.enums.BusinessType;
import com.brainhealth.customer.domain.ChatTemplate;
import com.brainhealth.customer.service.IChatTemplateService;
import com.brainhealth.common.utils.poi.ExcelUtil;
import com.brainhealth.common.core.page.TableDataInfo;

/**
 * 青竹聊天模板Controller
 * 
 * @author wolong
 * @date 2023-05-18
 */
@RestController
@RequestMapping("/customer/chatTemplate")
public class ChatTemplateController extends BaseController
{
    @Autowired
    private IChatTemplateService chatTemplateService;

    /**
     * 查询青竹聊天模板列表
     */
    @PreAuthorize("@ss.hasPermi('customer:chatTemplate:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChatTemplate chatTemplate)
    {
        startPage();
        List<ChatTemplate> list = chatTemplateService.selectChatTemplateList(chatTemplate);
        return getDataTable(list);
    }

    /**
     * 导出青竹聊天模板列表
     */
    @PreAuthorize("@ss.hasPermi('customer:chatTemplate:export')")
    @Log(title = "青竹聊天模板", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChatTemplate chatTemplate)
    {
        List<ChatTemplate> list = chatTemplateService.selectChatTemplateList(chatTemplate);
        ExcelUtil<ChatTemplate> util = new ExcelUtil<ChatTemplate>(ChatTemplate.class);
        util.exportExcel(response, list, "青竹聊天模板数据");
    }

    /**
     * 获取青竹聊天模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('customer:chatTemplate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(chatTemplateService.selectChatTemplateById(id));
    }

    /**
     * 新增青竹聊天模板
     */
    @PreAuthorize("@ss.hasPermi('customer:chatTemplate:add')")
    @Log(title = "青竹聊天模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChatTemplate chatTemplate)
    {
        return toAjax(chatTemplateService.insertChatTemplate(chatTemplate));
    }

    /**
     * 修改青竹聊天模板
     */
    @PreAuthorize("@ss.hasPermi('customer:chatTemplate:edit')")
    @Log(title = "青竹聊天模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChatTemplate chatTemplate)
    {
        return toAjax(chatTemplateService.updateChatTemplate(chatTemplate));
    }

    /**
     * 删除青竹聊天模板
     */
    @PreAuthorize("@ss.hasPermi('customer:chatTemplate:remove')")
    @Log(title = "青竹聊天模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(chatTemplateService.deleteChatTemplateByIds(ids));
    }
}
